import { request } from 'umi';

/**
 * 上传文件
 */
export const upload = (server: string, data: any) => {
  return request<any>(`${server}/api/file/upload`, {
    method: 'post',
    getResponse: true,
    headers: {
      'Content-Type': 'multipart/form-data',
    },
    data: {
      file: data,
    },
  });
};
/**
 * 上传文件
 */
export const uploadFormData = (server: string, data: any) => {
  return request<any>(`${server}/api/file/upload`, {
    method: 'post',
    getResponse: true,
    headers: {
      'Content-Type': 'multipart/form-data',
    },
    data: data,
  });
};

/**
 * 远程文件上传
 */
export const uploadNetworkFile = (server: string, data: any) => {
  return request<any>(`${server}/api/file/uploadNetworkFile`, {
    method: 'get',
    getResponse: true,
    data: {
      fileUrl: data,
    },
  });
};
